<?php

namespace Kunfeng\Dify\Event;

/**
 * 消息结束事件
 */
class MessageEndEvent extends BaseEvent
{
    private $messageId;
    private $conversationId;
    private $metadata;

    public function __construct(
        string $event,
        array $data = []
    ) {
        parent::__construct($event, $data);
        
        $this->messageId = $data['message_id'] ?? '';
        $this->conversationId = $data['conversation_id'] ?? '';
        $this->metadata = $data['metadata'] ?? null;
    }

    /**
     * 从数组创建事件
     */
    public static function fromArray(array $data)
    {
        return new self($data['event'] ?? 'message_end', $data);
    }

    public function getMessageId(): string
    {
        return $this->messageId;
    }

    public function getConversationId(): string
    {
        return $this->conversationId;
    }

    public function getMetadata(): ?array
    {
        return $this->metadata;
    }
}
